﻿using Xejen.Communication.Configuration;
using Xejen.Communication.Endpoints;
using Xejen.Communication.Socket.Configuration;
using System.Threading;
using System.Threading.Tasks;

namespace Xejen.Communication.Socket.Communicator
{
    /// <summary>
    /// 提供Socket通讯器专用接口
    /// </summary>
    /// <creator>marc</creator>
    public interface ISocketCommunicator : ICommunicator<SocketConfig, HeartbeatConfig>
    {
        /// <inheritdoc cref="Xejen.Communication.Socket.Configuration.ConnectionConfig"/>
        ConnectionConfig CurrentConnection { get; }

        /// <summary>
        /// 发送socket请求
        /// </summary>
        /// <param name="connectionConfig">修改配置信息</param>
        /// <param name="input">待发送的数据字节</param>
        /// <param name="timeout">超时时间，单位：毫秒</param>
        /// <param name="cancellationToken">是否取消的令牌</param>
        /// <returns></returns>
        Task<SocketResponse> SendAsync(byte[] input, ConnectionConfig connectionConfig = null, int timeout = -1, CancellationToken cancellationToken = default);
        /// <summary>
        /// 发送socket请求
        /// </summary>
        /// <param name="connectionConfig">修改配置信息</param>
        /// <param name="input">待发送的数据字符串</param>
        /// <param name="timeout">超时时间，单位：毫秒</param>
        /// <param name="cancellationToken">是否取消的令牌</param>
        /// <returns></returns>
        Task<SocketResponse> SendAsync(string input, ConnectionConfig connectionConfig = null, int timeout = -1, CancellationToken cancellationToken = default);
    }
}